home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Text⁄Files / Dialectic 1.1 Source / Dialectic ƒ / Dialectic code / dialectic dispatch.c next >
Encoding:
C/C++ Source or Header  |  1994-02-16  |  4.0 KB  |  155 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        dialectic dispatch.c
  4.  
  5. Purpose:    This module handles dispatching to the different conversion
  6.             routines.
  7.  
  8.  
  9. Dialectic -=- dialect text conversion extraordinare
  10. Copyright ©1994, Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "dialectic dispatch.h"
  30. #include "dialectic utilities.h"
  31. #include "program globals.h"
  32.  
  33. unsigned char    gWhichDialect;
  34. unsigned long    gInputOffset;
  35. unsigned long    gOutputOffset;
  36. Ptr                gInputBuffer;
  37. Ptr                gOutputBuffer;
  38. Boolean            gInputNeedsUpdate;
  39. Boolean            gOutputNeedsUpdate;
  40. unsigned long    gAbsoluteOffset;
  41. unsigned long    gInputLength;
  42. Boolean            gInWord;
  43. Boolean            gSeenI;
  44. Boolean            gSeenBackslash;
  45. int                gCurlyLevel;
  46.  
  47. void ConvertDispatch(void)
  48. {
  49.     unsigned char    oneChar;
  50.     
  51.     if (gUseRTF)
  52.     {
  53.         oneChar=ThisChar();
  54.         if ((oneChar=='}') && (gCurlyLevel>0))
  55.             gCurlyLevel--;
  56.         else if (oneChar=='{')
  57.             gCurlyLevel++;
  58.         
  59.         if (oneChar==0x5c)
  60.             gSeenBackslash=TRUE;
  61.         
  62.         if ((gCurlyLevel>2) || (gSeenBackslash))
  63.         {
  64.             StoreChar(oneChar);
  65.             InputPlus(1);
  66.             if ((oneChar==' ') || (IsNumeric(oneChar)))
  67.                 gSeenBackslash=FALSE;
  68.             return;
  69.         }
  70.     }
  71.     
  72.     switch (gWhichDialect)
  73.     {
  74.         case kChef:        ConvertChef();        break;
  75.         case kFudd:        ConvertFudd();        break;
  76.         case kWAREZ:    ConvertWAREZ();        break;
  77.         case kUbby:        ConvertUbby();        break;
  78.         case kOlde:        ConvertOlde();        break;
  79.     }
  80. }
  81.  
  82. void SetupSuffix(void)
  83. {
  84.     switch (gWhichDialect)
  85.     {
  86.         case kChef:
  87.             if (outputFS.name[0]>26)
  88.                 outputFS.name[0]=26;
  89.             outputFS.name[++(outputFS.name[0])]='.';
  90.             outputFS.name[++(outputFS.name[0])]='b';
  91.             outputFS.name[++(outputFS.name[0])]='o';
  92.             outputFS.name[++(outputFS.name[0])]='r';
  93.             outputFS.name[++(outputFS.name[0])]='k';
  94.             break;
  95.         case kFudd:
  96.             if (outputFS.name[0]>26)
  97.                 outputFS.name[0]=26;
  98.             outputFS.name[++(outputFS.name[0])]='.';
  99.             outputFS.name[++(outputFS.name[0])]='f';
  100.             outputFS.name[++(outputFS.name[0])]='u';
  101.             outputFS.name[++(outputFS.name[0])]='d';
  102.             outputFS.name[++(outputFS.name[0])]='d';
  103.             break;
  104.         case kWAREZ:
  105.             if (outputFS.name[0]>26)
  106.                 outputFS.name[0]=26;
  107.             outputFS.name[++(outputFS.name[0])]='.';
  108.             outputFS.name[++(outputFS.name[0])]='K';
  109.             outputFS.name[++(outputFS.name[0])]='0';
  110.             outputFS.name[++(outputFS.name[0])]='0';
  111.             outputFS.name[++(outputFS.name[0])]='L';
  112.             break;
  113.         case kUbby:
  114.             if (outputFS.name[0]>26)
  115.                 outputFS.name[0]=26;
  116.             outputFS.name[++(outputFS.name[0])]='.';
  117.             outputFS.name[++(outputFS.name[0])]='u';
  118.             outputFS.name[++(outputFS.name[0])]='b';
  119.             outputFS.name[++(outputFS.name[0])]='b';
  120.             outputFS.name[++(outputFS.name[0])]='y';
  121.             break;
  122.         case kOlde:
  123.             if (outputFS.name[0]>26)
  124.                 outputFS.name[0]=26;
  125.             outputFS.name[++(outputFS.name[0])]='.';
  126.             outputFS.name[++(outputFS.name[0])]='O';
  127.             outputFS.name[++(outputFS.name[0])]='l';
  128.             outputFS.name[++(outputFS.name[0])]='d';
  129.             outputFS.name[++(outputFS.name[0])]='e';
  130.             break;
  131.     }
  132. }
  133.  
  134. void SetSuffixMenuItem(MenuHandle theMenu, int theItem)
  135. {
  136.     switch (gWhichDialect)
  137.     {
  138.         case kChef:
  139.             SetItem(theMenu, theItem, "\pAdd “.bork” suffix");
  140.             break;
  141.         case kFudd:
  142.             SetItem(theMenu, theItem, "\pAdd “.fudd” suffix");
  143.             break;
  144.         case kWAREZ:
  145.             SetItem(theMenu, theItem, "\pAdd “.K00L” suffix");
  146.             break;
  147.         case kUbby:
  148.             SetItem(theMenu, theItem, "\pAdd “.ubby” suffix");
  149.             break;
  150.         case kOlde:
  151.             SetItem(theMenu, theItem, "\pAdd “.Olde” suffix");
  152.             break;
  153.     }
  154. }
  155.